Skip to content

feat: QuickSight v3.0.0 — auto-subscribe, group-based permissions, EventBridge user sync#83

Merged
chrisns merged 6 commits into
mainfrom
feat/quicksight-auto-group-sync
Feb 28, 2026
Merged

feat: QuickSight v3.0.0 — auto-subscribe, group-based permissions, EventBridge user sync#83
chrisns merged 6 commits into
mainfrom
feat/quicksight-auto-group-sync

Conversation

@chrisns
Copy link
Copy Markdown
Member

@chrisns chrisns commented Feb 28, 2026

Summary

Major overhaul of the QuickSight dashboard template (v2.4.0 → v3.0.0) to make it fully self-contained and deployable in fresh ISB sandbox accounts where QuickSight has never been configured.

What changed

  • Auto-subscribe QuickSight: New setup Lambda + custom resource that handles the full QuickSight lifecycle — subscribes to Enterprise edition, waits for activation, registers an IAM admin user, enables SPICE auto-purchase, and creates the ndx-all-users group. Handles all subscription states (active, unsubscribed, in-progress, failed) with polling and retry logic.
  • Group-based permissions: All three QuickSight resources (DataSource, DataSet, Dashboard) now grant permissions to the ndx-all-users group instead of a hardcoded SSO username. Removes the QuickSightUsername parameter entirely.
  • EventBridge auto-group-sync: New EventBridge rule + Lambda that catches CloudTrail events for QuickSight user creation (RegisterUser, BatchCreateUser, CreateUser) and automatically adds new users to the ndx-all-users group. Handles console self-provisioning events where the username is in serviceEventDetails with Role:Session format (converted to Role/Session).
  • RegisterUser retry logic: The setup Lambda retries RegisterUser up to 6 times with backoff for PreconditionNotMetException, which occurs after rapid subscribe/unsubscribe cycles when QuickSight's IAM integration hasn't propagated.
  • Versioned bucket emptying: Data generator Lambda now properly empties versioned S3 buckets on stack delete by iterating all object versions and delete markers, preventing stack deletion failures.
  • SAM transform removed: Template is now pure CloudFormation — no SAM build/deploy required. Compatible with ISB blueprint deployment pipeline.
  • Removed parameters: AutoCleanupHours (lifecycle rules replaced by explicit cleanup) and QuickSightUsername (replaced by group-based permissions).

New resources (8)

Resource Type Purpose
QuickSightSetupRole AWS::IAM::Role IAM role for QuickSight subscription, user, and group management
QuickSightSetupFunction AWS::Lambda::Function Auto-subscribes QuickSight, registers admin user, creates group
QuickSightSetupLogGroup AWS::Logs::LogGroup 7-day retention for setup Lambda
QuickSightSetupTrigger AWS::CloudFormation::CustomResource Triggers setup on stack create/update
QuickSightGroupSyncFunction AWS::Lambda::Function Adds new QuickSight users to ndx-all-users group
QuickSightGroupSyncLogGroup AWS::Logs::LogGroup 7-day retention for sync Lambda
QuickSightGroupSyncRule AWS::Events::Rule EventBridge rule matching QuickSight user creation events
QuickSightGroupSyncPermission AWS::Lambda::Permission Allows EventBridge to invoke sync Lambda

Key design decisions

  1. Group-based over user-based permissions — decouples deployment from user identity, scales to multiple users automatically
  2. Idempotent subscription handling — setup Lambda handles all QuickSight states rather than assuming clean slate
  3. Event-driven user sync — EventBridge + CloudTrail rather than polling or manual steps
  4. Subscription left intact on delete — only the admin user is cleaned up; AWS Nuke handles full teardown in ISB sandbox model
  5. Pure CloudFormation — SAM transform removed for ISB blueprint compatibility

Test plan

  • Deployed stack fresh to sandbox account (us-west-2) with no prior QuickSight subscription
  • QuickSight auto-subscribed, admin user registered (with retry on PreconditionNotMetException)
  • ndx-all-users group created, admin user added
  • Logged into QuickSight console as SSO user — CreateUser service event fired
  • Sync Lambda extracted username from serviceEventDetails with colon-to-slash conversion
  • CreateGroupMembership succeeded — user added to ndx-all-users
  • Dashboard visible in QuickSight console without manual permission grants
  • Stack delete tested — versioned bucket emptied cleanly

Remove AutoCleanupHours parameter and S3 lifecycle rules (ISB handles
cleanup via AWS Nuke), fix Bedrock IAM policy region mismatch to
match Lambda's hardcoded us-east-1, remove incorrect Amazon Lex
references from scenarios.yaml, add CAPABILITY_AUTO_EXPAND for SAM
transform StackSet support, and create BLUEPRINT.md registration guide.
Template uses explicit RoleName which requires CAPABILITY_NAMED_IAM.
StackSet must be created in the ISB deployment region (e.g. us-west-2),
not necessarily the target deployment region.
- Migrate admin password from Math.random() to Secrets Manager
- Make CDK stack environment-agnostic (Fn::GetAZs for StackSet portability)
- Hardcode deployment settings and DESTROY removal policies
- Bump Fargate to 1 vCPU / 2 GB for faster Drupal initialization
- Add per-module progress reporting to init-status page
- Add CI workflow for CDK synth with bootstrap stripping and validation
- Add ISB hub stack with StackSet for localgov-drupal scenario
- Update scenarios.yaml (remove params, add CAPABILITY_NAMED_IAM)
- Add BLUEPRINT.md with ISB deployment guide
- Delete stub template.yaml (CI generates from CDK)
Replace ~40 sequential drush pm:enable calls (each spawning a separate
PHP process) with a single drush pm:install call passing all modules.
Eliminates redundant Drush bootstraps, dependency resolutions, and
intermediate cache rebuilds. Same approach for custom NDX modules.
CloudFormation dynamic references ({{resolve:secretsmanager:...}}) are
not resolved in stack outputs, so the raw reference string was shown
instead of the actual password. Changed output to a Secrets Manager
console URL where users can retrieve the password.

Also allow docker-build workflow_dispatch to push from any branch.
QuickSight has no "all users" wildcard for permissions — only user/group
ARN principals. The ndx-all-users group has permissions on all three
QuickSight resources (DataSource, DataSet, Dashboard), but new users
who self-provision via the console aren't automatically in the group.

Add an EventBridge rule + Lambda that catches CloudTrail events for
QuickSight user creation (RegisterUser, BatchCreateUser, CreateUser)
and auto-adds the new user to the ndx-all-users group.

Key implementation details:
- EventBridge rule omits detail-type to catch both API calls and
  service events (console self-provisioning uses AwsServiceEvent)
- Username extraction handles three event structures: responseElements,
  requestParameters, and serviceEventDetails (console self-provisioning)
- Console CreateUser events use "Role:Session" format but QuickSight
  usernames use "Role/Session" — the Lambda converts accordingly
- Idempotent: silently handles ResourceExistsException
- Best-effort: all errors logged, never fatal
- Reuses existing QuickSightSetupRole (already has CreateGroupMembership)

Also fixes QuickSight setup reliability:
- Add retry with backoff for RegisterUser PreconditionNotMetException,
  which occurs after rapid subscribe/unsubscribe cycles when QuickSight
  IAM integration hasn't fully propagated
@chrisns chrisns changed the title feat: auto-add QuickSight users to ndx-all-users group via EventBridge feat: QuickSight v3.0.0 — auto-subscribe, group-based permissions, EventBridge user sync Feb 28, 2026
@chrisns chrisns added this pull request to the merge queue Feb 28, 2026
Merged via the queue into main with commit 98ff36b Feb 28, 2026
7 checks passed
@chrisns chrisns deleted the feat/quicksight-auto-group-sync branch February 28, 2026 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant